﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FaceSharp.Api;
using FaceSharp.Api.Types;

namespace FaceSharp.MVC.Filters
{
    public class FacebookAuthorization : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var facebookGraphApiFilter = new FacebookGraphApiFilter();
            User user;
            facebookGraphApiFilter.ValidateContext(httpContext,out user);
            if (user != null)
            {
                return true;
            }

            return base.AuthorizeCore(httpContext);
        }
    }
}